package com.ccx.coachsite.util;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	private static final int VERSION = 1;
	private static final String DATA = "data.db3";
	public DBHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}
	public DBHelper(Context context,String name){
		super(context,name,null,VERSION);
	}
	public DBHelper(Context context,String name,int version){
		super(context, name,null,version);
	}
	public DBHelper(Context context){
		super(context, DATA, null ,VERSION);
	}
	@Override
	public void onCreate(SQLiteDatabase db) {

		String down_item_sql = ""
				+ "CREATE TABLE down_item "
				+ "  ( "
				+ "     sid           VARCHAR(50) PRIMARY KEY, "
				+ "     title         VARCHAR(50), "
				+ "     icon_path     VARCHAR(50), "
				+ "     icon_url      VARCHAR(100), "
				+ "     pkg_name      VARCHAR(50), "
				+ "     avail_version VARCHAR(20), "
				+ "     file_bytes    LONG, "
				+ "     download_url  VARCHAR(100), "
				+ "     file_path     VARCHAR(50) "
				+ "  ) ";
		
		String install_item_sql = ""
				+ "CREATE TABLE install_item "
				+ "  ( "
				+ "     sid           VARCHAR(50) PRIMARY KEY, "
				+ "     title         VARCHAR(50), "
				+ "     icon_path     VARCHAR(50), "
				+ "     icon_url      VARCHAR(100), "
				+ "     pkg_name      VARCHAR(50), "
				+ "     avail_version VARCHAR(20), "
				+ "     file_bytes    LONG, "
				+ "     download_url  VARCHAR(100), "
				+ "     file_path     VARCHAR(50) "
				+ "  ) ";
		
		db.execSQL(down_item_sql);
		db.execSQL(install_item_sql);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub

	}

}
